#include<bits/stdc++.h>
using namespace std;
int t,m,n,l,v,dd[1000008],vv[1000008],aa[1000008],p[1000008],flag=0,ans;
double vf[1000008];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--)
    {
        flag=0;
        ans=0;
        scanf("%d%d%d%d",&n,&m,&l,&v);
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&dd[i],&vv[i],&aa[i]);
            if(aa[i])flag=1;
        }
        for(int i=1;i<=m;i++){scanf("%d",&p[i]);}
        sort(p+1,p+m+1);
        if(flag==0)
        {
            int las=p[m];
            for(int i=1;i<=n;i++)
            {
                if(las>=dd[i]&&vv[i]>v)
                {
                    ans++;
                }
            }
            int clos=m-1;
            if(ans==0)clos=m;
            printf("%d %d\n",ans,clos);
        }
        if(flag==1)
        {
            int las=p[m];

            for(int i=1;i<=n;i++)
            {
                int s=las-dd[i];
                if(s>=0)vf[i]=sqrt((double)vv[i]*vv[i]+2*aa[i]*s);
                if(vf[i]>(double)v)
                {
                    ans++;
                }
            }
            int clos=m-1;
            if(ans==0)clos=m;
            printf("%d %d\n",ans,clos);
        }
    }
    return 0;
}
